/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: #1e272e;
    color: #dfe6e9;
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

/* 背景代码雨效果 */
#code-rain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.15;
}

#game-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.screen {
    background-color: rgba(30, 39, 46, 0.85);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    padding: 30px;
    text-align: center;
    border: 1px solid #3498db;
    backdrop-filter: blur(5px);
    transition: all 0.5s ease;
}

.screen:hover {
    box-shadow: 0 15px 40px rgba(52, 152, 219, 0.3);
    transform: translateY(-5px);
}

.hidden {
    display: none !important;
}

h1 {
    font-size: 3.5rem;
    margin-bottom: 20px;
    color: #3498db;
    text-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
    letter-spacing: 2px;
    font-weight: 800;
}

h2 {
    font-size: 2rem;
    margin-bottom: 15px;
    color: #3498db;
    font-weight: 600;
}

h3 {
    font-size: 1.5rem;
    margin: 15px 0;
    color: #dfe6e9;
    font-weight: 500;
}

p {
    margin-bottom: 15px;
    font-size: 1.1rem;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 5px;
    padding: 10px 20px;
    font-size: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

button:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(20, 20);
        opacity: 0;
    }
}

.primary-btn {
    background-color: #3498db;
    color: white;
    font-weight: bold;
    padding: 15px 35px;
    font-size: 1.3rem;
    margin: 25px 0;
    border-radius: 50px;
    letter-spacing: 1px;
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.primary-btn:hover {
    background-color: #2980b9;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(52, 152, 219, 0.6);
}

.primary-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(52, 152, 219, 0.4);
}

.secondary-btn {
    background-color: #7f8c8d;
    color: white;
    margin: 10px;
    border-radius: 50px;
    font-weight: 500;
    box-shadow: 0 3px 10px rgba(127, 140, 141, 0.3);
}

.secondary-btn:hover {
    background-color: #95a5a6;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(127, 140, 141, 0.5);
}

ul {
    list-style-position: inside;
    margin-bottom: 15px;
    text-align: left;
    max-width: 500px;
    margin: 0 auto 20px;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 15px 20px;
    border-radius: 10px;
}

li {
    margin-bottom: 8px;
    padding-left: 10px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    #game-container {
        padding: 10px;
    }
    
    .screen {
        padding: 20px;
    }
    
    h1 {
        font-size: 2.5rem;
    }
    
    h2 {
        font-size: 1.8rem;
    }
    
    .primary-btn {
        padding: 12px 25px;
        font-size: 1.1rem;
    }
}

#game-scene {
    position: relative;
    width: 100%;
    height: 200px;
    background-image: url('../assets/images/backgrounds/city.png');
    background-repeat: repeat-x;
    background-position: 0 bottom;
    overflow: hidden;
    border-radius: 8px;
    margin-top: 20px;
}

/* 背景动画 */
@keyframes scrollBackground {
    from { background-position: 0 bottom; }
    to { background-position: -1000px bottom; }
}

/* 根据打字速度调整背景滚动速度 */
.scroll-slow {
    animation: scrollBackground 30s linear infinite;
}

.scroll-medium {
    animation: scrollBackground 20s linear infinite;
}

.scroll-fast {
    animation: scrollBackground 10s linear infinite;
}

.scroll-very-fast {
    animation: scrollBackground 5s linear infinite;
}

/* 角色样式 */
.thief-character {
    position: absolute;
    bottom: 20px;
    left: 50px;
    width: 60px;
    height: 60px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 10;
    transition: transform 0.3s ease, left 0.3s ease-out, width 0.5s ease, height 0.5s ease, background-color 0.5s ease, border-radius 0.5s ease;
}

.police-character {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 60px;
    height: 60px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 5;
}

/* 小偷角色状态样式 */
.thief-walking {
    background-color: #3498db;
    border-radius: 50%;
    position: relative;
}

.thief-walking:before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    width: 20px;
    height: 20px;
    background-color: #fff;
    border-radius: 50%;
}

.thief-walking:after {
    content: '';
    position: absolute;
    top: 15px;
    left: 15px;
    width: 10px;
    height: 10px;
    background-color: #000;
    border-radius: 50%;
}

.thief-running {
    background-color: #2ecc71;
    border-radius: 40% 40% 50% 50%;
    position: relative;
    transform: rotate(10deg);
}

.thief-running:before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    width: 20px;
    height: 20px;
    background-color: #fff;
    border-radius: 50%;
}

.thief-running:after {
    content: '';
    position: absolute;
    top: 15px;
    left: 15px;
    width: 10px;
    height: 10px;
    background-color: #000;
    border-radius: 50%;
}

.thief-motorcycle {
    background-color: #e74c3c;
    border-radius: 30% 50% 50% 30%;
    position: relative;
}

.thief-motorcycle:before {
    content: '';
    position: absolute;
    top: 5px;
    left: 10px;
    width: 30px;
    height: 20px;
    background-color: #34495e;
    border-radius: 50% 50% 0 0;
}

.thief-motorcycle:after {
    content: '';
    position: absolute;
    bottom: 5px;
    left: 5px;
    right: 5px;
    height: 15px;
    background-color: #7f8c8d;
    border-radius: 50%;
}

/* 优化汽车状态样式 */
.thief-car {
    background-color: #f1c40f;
    border-radius: 10px;
    position: relative;
    height: 30px !important;
    width: 70px !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.thief-car:before {
    content: '';
    position: absolute;
    top: -15px;
    left: 15px;
    width: 40px;
    height: 20px;
    background-color: #3498db;
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2);
}

.thief-car:after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 10px;
    width: 12px;
    height: 12px;
    background-color: #2c3e50;
    border-radius: 50%;
    box-shadow: 45px 0 0 #2c3e50;
}

/* 添加车灯 */
.thief-car::after {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    background-color: #e74c3c;
    border-radius: 50%;
    box-shadow: 0 0 5px #e74c3c;
}

/* 添加车窗 */
.thief-car::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 20px;
    width: 30px;
    height: 15px;
    background-color: #2c3e50;
    border-radius: 5px 5px 0 0;
}

.police-character {
    background-color: #e74c3c;
    border-radius: 50%;
}

/* 踉跄效果 */
.stumble {
    animation: stumble 0.5s ease;
}

@keyframes stumble {
    0% { transform: translateX(0) rotate(0); }
    25% { transform: translateX(-10px) rotate(-10deg); }
    50% { transform: translateX(5px) rotate(5deg); }
    75% { transform: translateX(-5px) rotate(-5deg); }
    100% { transform: translateX(0) rotate(0); }
}

/* 警察滑倒效果 */
.slip {
    animation: slip 1s ease;
}

@keyframes slip {
    0% { transform: translateY(0) rotate(0); }
    30% { transform: translateY(-10px) rotate(30deg); }
    60% { transform: translateY(0) rotate(-10deg); }
    100% { transform: translateY(0) rotate(0); }
}

/* 速度提升效果 */
.speed-boost {
    animation: speedBoost 0.5s infinite alternate;
}

@keyframes speedBoost {
    from { filter: brightness(1); }
    to { filter: brightness(1.5) drop-shadow(0 0 5px #3498db); }
}

/* 护盾效果 */
.shield-effect {
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    border: 2px solid #3498db;
    box-shadow: 0 0 10px #3498db;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.5; transform: scale(1); }
    to { opacity: 0.8; transform: scale(1.1); }
}

/* 按键效果 */
.key-effect {
    position: absolute;
    font-size: 24px;
    font-weight: bold;
    animation: flyUp 1s ease-out;
    z-index: 20;
}

.key-effect.correct {
    color: #2ecc71;
}

.key-effect.incorrect {
    color: #e74c3c;
}

@keyframes flyUp {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-50px); opacity: 0; }
}

/* 道具效果 */
.item-effect {
    position: absolute;
    width: 40px;
    height: 40px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 15;
}

.banana-effect {
    background-image: url('../assets/images/items/banana.png');
    animation: spin 1s ease;
}

.coffee-effect {
    background-image: url('../assets/images/items/coffee.png');
    animation: bounce 1s ease;
}

@keyframes spin {
    0% { transform: rotate(0) scale(1); opacity: 1; }
    100% { transform: rotate(360deg) scale(0); opacity: 0; }
}

@keyframes bounce {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    50% { transform: translateY(-20px) scale(1.2); opacity: 0.8; }
    100% { transform: translateY(-40px) scale(0); opacity: 0; }
}

/* 鼓励文字 */
.encouragement {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: bold;
    color: #f39c12;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    animation: fadeInOut 1.5s ease-in-out;
    z-index: 30;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

/* 文本显示区域修复 */
#typing-area {
    width: 100%;
    margin: 20px 0;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    position: relative;
}

#text-display {
    font-size: 18px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    text-align: left;
    direction: ltr;
    width: 100%;
}

.typed {
    color: #7f8c8d;
}

.current {
    background-color: #f1c40f;
    color: #000;
    padding: 0 2px;
    border-radius: 2px;
}

/* 游戏场景层 */
.scene-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* 背景层 */
#background-layer {
    z-index: 1;
}

.sky {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60%;
    background: linear-gradient(to bottom, #87CEEB, #E0F7FA);
}

.buildings {
    position: absolute;
    bottom: 40%;
    left: 0;
    width: 200%;
    height: 40%;
    background-color: #34495e;
    background-image: none;
}

/* 街道层 */
#street-layer {
    z-index: 2;
}

.street {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 40%;
    background-color: #7f8c8d;
    background-image: none;
}

/* 障碍物 */
.obstacle {
    position: absolute;
    bottom: 20px;
    width: 30px;
    height: 30px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 8;
}

.obstacle-trash {
    background-color: #e74c3c;
    border-radius: 5px;
    width: 20px;
    height: 30px;
}

.obstacle-cone {
    background-color: #f39c12;
    width: 20px;
    height: 30px;
    clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}

.obstacle-hydrant {
    background-color: #c0392b;
    width: 20px;
    height: 30px;
    border-radius: 5px 5px 0 0;
}

/* 角色层 */
#character-layer {
    z-index: 3;
}

/* 距离指示器改进 */
#distance-bar {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    height: 8px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

#distance-indicator {
    height: 100%;
    width: 80%;
    background-color: #3498db;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* 里程碑标记 */
.milestone {
    position: absolute;
    bottom: 20px;
    width: 20px;
    height: 40px;
    background-color: #f39c12;
    border-radius: 2px;
    z-index: 7;
}

.milestone:after {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    width: 20px;
    height: 10px;
    background-color: #e67e22;
    border-radius: 2px;
}

/* 背景动画调整 */
@keyframes scrollBuildings {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

@keyframes scrollStreet {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* 根据打字速度调整背景滚动速度 */
.scroll-slow .buildings {
    animation: scrollBuildings 60s linear infinite;
}
.scroll-slow .street {
    animation: scrollStreet 30s linear infinite;
}

.scroll-medium .buildings {
    animation: scrollBuildings 40s linear infinite;
}
.scroll-medium .street {
    animation: scrollStreet 20s linear infinite;
}

.scroll-fast .buildings {
    animation: scrollBuildings 20s linear infinite;
}
.scroll-fast .street {
    animation: scrollStreet 10s linear infinite;
}

.scroll-very-fast .buildings {
    animation: scrollBuildings 10s linear infinite;
}
.scroll-very-fast .street {
    animation: scrollStreet 5s linear infinite;
}
